package jd1.aop;

import jd1.entity.Equip;
import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggerAspect {
    private static final Logger log = LoggerFactory.getLogger(LoggerAspect.class);

    public void before(JoinPoint joinPoint) {
        log.info("升级装备");
        Object[] args = joinPoint.getArgs();
        if (args.length > 0 ) {
            Equip equip = (Equip) args[0]; // 强制转换为 Equip 对象
            if (equip.getType().equals("指环")) {
                equip.setName("紫色梦幻");
                equip.setAttackPlus(equip.getAttackPlus() + 6); // 增加攻击力
                equip.setDefensePlus(equip.getDefensePlus() + 6); // 增加防御力
                log.info("升级成功");
            } else {
                log.info("升级失败");
            }
        }
    }
}
